package com.tuanzi.loan.business.service.family.impl;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuanzi.loan.business.entity.family.UserBlacklist;
import com.tuanzi.loan.business.repository.family.UserBlacklistRepository;
import com.tuanzi.loan.business.service.family.UserBlacklistService;
import com.tuanzi.loan.core.repository.JPAAuditRepository;
import com.tuanzi.loan.core.service.BaseAuditServiceImpl;

/**
 * 
 * @author Xumiaohang 2017/11/16
 *
 */
@Service
@Transactional
public class UserBlacklistServiceImpl extends BaseAuditServiceImpl<UserBlacklist, Long> implements UserBlacklistService {

	@Autowired
	private UserBlacklistRepository userBlacklistRepository;

	@Override
	protected JPAAuditRepository<UserBlacklist, Long> getRepository() {
		return userBlacklistRepository;
	}

	// 根据号码和类型检查重复的记录
	@Override
	public List<String> repeatCheck(List<String> list, String type) {
		return userBlacklistRepository.repeatCheck(list, type);
	}

	@Override
	public List<String> findMobnumsBy(List<String> mobnums, String type) {
		return userBlacklistRepository.findAllByMobnumInAndType(mobnums, type).stream().map(UserBlacklist::getMobnum).collect(Collectors.toList());
	}
}
